from django.conf.urls import url
from . import views


urlpatterns = [
    # 注册页面
    url('^register/$', views.RegisterView.as_view(), name='register'),
    # 检查用户名是否已注册
    url(r'^usernames/(?P<username>[a-zA-Z0-9_-]{5,20})/count/$', views.UsernameCountView.as_view()),
    # 检查手机号是否已注册
    url(r'^mobiles/(?P<mobile>1[345789]\d{9})/count/$', views.MobileCountView.as_view()),
    # 登录页面
    url('^login/$', views.LoginView.as_view(), name='login'),
    # 登出
    url('^logout/$', views.LogoutView.as_view(), name='logout'),
    # 个人中心——主页面
    url('^info/$', views.UserCenterInfoView.as_view(), name='info'),
    # url('^info/$', login_required(views.UserCenterInfoView.as_view())),
    # 发送验证邮件给用户邮箱
    url('^emails/$', views.EmailView.as_view()),
    # 邮箱验证功能，验证邮件中的链接使用此路由
    url('^emails/verification/$', views.EmailActiveView.as_view()),
    # 个人中心——收货地址
    url('^addresses/$', views.AddressView.as_view(), name='address'),
    # 新增用户收货地址
    url('^addresses/create/$', views.AddressCreateView.as_view()),
    # 修改/删除用户收货地址
    url('^addresses/(?P<address_id>\d+)/$', views.AddressEditView.as_view()),
    # 设置默认收货地址
    url('^addresses/(?P<address_id>\d+)/default/$', views.AddressDefaultView.as_view()),
    # 修改收货地址的标题
    url('^addresses/(?P<address_id>\d+)/title/$', views.AddressTitleView.as_view()),
    # 个人中心——修改密码
    url('^password/$', views.PwdView.as_view(), name='password'),
]
